<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;


class CreateRentClothesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('rent_clothes', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id')->comment('用户id');
            $table->integer('shop_id')->comment('=shop.id');
            $table->tinyInteger('type')->default(0)->comment('1线上2线下3换购');
            $table->tinyInteger('pay_type')->default(0)->comment('1余额2微信3E格码');
            $table->dateTime('pay_at')->nullable()->comment('付款时间');            
            $table->integer('addr_id')->default(0)->comment('=user_addrs.id');
            $table->decimal('total_price','10','2')->default(0)->comment('订单金额');
            $table->decimal('total_e','10','4')->default(0)->comment('订单金额(E格码)');
            $table->string('attr_list')->default('')->comment('商品属性数据');
            $table->string('out_trade_no')->default('')->comment('商户订单号');
            $table->integer('rent_time')->default(0)->comment('租衣时间');
            $table->integer('back_time')->default(0)->comment('归还时间');
            $table->tinyInteger('is_apply')->default(0)->comment('是否申请还衣');
            $table->tinyInteger('status')->comment('租衣状态1在租2已归还3线上待发货4线上已发货5线上已收货6线上已归还7售后订单');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `rent_clothes` comment '租衣表';");

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('rent_clothes');
    }
}
